<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
    margin: 0;
    padding: 0;
}
ul,ol {
    list-style: none;
}
.banner {
    width: 100%;
    height: 500px;
    position: relative;
    margin: 0px 0px;
}
.banner ul > li {
    width: 100%;
    height: 500px;
    position: absolute; 
    left: 0;
    top: 0;
    opacity: 0;
}
.banner ul .active {
    opacity: 1; 

}
.banner ol .active {
    background-color: yellow;

}
.banner ol {
    width: 200px;
    height: 30px;
    position: absolute;
        left: 30px;
    bottom: 30px;
    display: flex; 
    justify-content: space-around; 
    align-items: center; 
    background-color: rgba(0, 0, 0, 0.5); 
    border-radius: 15px;
}

.banner ol > li {
    width: 30px;
    height: 30px;
    background-color: #fff; 
    border-radius: 50px;
    cursor: pointer;
}

.banner ul .active {
    opacity: 1; 
    background-color: rgba(56, 31, 146);
}

.banner > div {
    width: 40px;
    height: 40px;
    line-height: 40px; 
    text-align: center; 
    background-color: rgba(0, 0, 0, 0.5);
    position: absolute; 
    top: 50%; 
    color: #fff;
    font-size: 25px;
    cursor: pointer; 
    border-radius: 5px;
}

.left {
    left: 0px;
}
.right {
    right: 0px;
}
</style>
</head>
<body>

<div class="banner">

<ul>
<li class="active">
<img src="../images/tb01.jpg" width="100%" height="500px" />
</li>
<li>
<img src="../images/tb02.jpg" width="100%" height="500px" />
</li>
<li>
<img src="../images/tb03.jpg" width="100%" height="500px" />
</li>
<li>
<img src="../images/tb04.jpg" width="100%" height="500px" />
</li>
</ul>

<ol>
<li class="active" onclick="changeOne(0)"></li>
<li onclick="changeOne(1);"></li>
<li onclick="changeOne(2);"></li>
<li onclick="changeOne(3);" ></li>
</ol>

<div class="left"><a>&lt;</a></div>

<div class="right">&gt;</div>
</div>
</body>
</html>
<script>
var imgs = document.querySelectorAll("ul > li"); 
var points = document.querySelectorAll("ol > li"); 

var left = document.querySelector(".left");
var right = document.querySelector(".right");



var index=0;
function changeOne(type){
    imgs[index].className="";

    points[index].className='';

if(type==true){
    index++;
}else if(type==false){
    index--;
}else{
    index==type;
}

if(index>=imgs.length){
    index=0;
}
if(index<0){
    index=imgs.length-1;
}

imgs[index].className="active";
points[index].className="active";
}
left.onclick = function () {
    changeOne(false);
};

right.onclick = function () {
    changeOne(true);
};

setInterval(function () {
    changeOne(true);
}, 2000);




</script>